<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style type="text/css">
  html { height: 100% }
  body { height: 100%; margin: 0; padding: 0 }
  #map_canvas { height: 100% }
</style>

<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
	<script type="text/javascript" charset="utf-8" src="js/cordova-2.5.0.js"></script>

<script type="text/javascript"
    src="http://maps.googleapis.com/maps/api/js?sensor=true">
</script>
<script type="text/javascript">
var map;
var marcador;
  function initialize() {
	var latlng = new google.maps.LatLng(-12.119088,-77.029819);
    var myOptions = {
      zoom: 14,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP,
      zoomControl: true
    };
    map = new google.maps.Map(document.getElementById("map_canvas"),
        myOptions);
  /*marcador = new google.maps.Marker( {
    	var icono = "icons/man.png"
		position: latlng,
		map:map	
		icon: new google.maps.MarkerImage(icono),
	}); */
   }
  function buscarCrap(){
	  alert("dentro de procesar");
    	
	  $.getJSON( "http://192.168.16.100/adm/buscakfc.php?jsoncallback=1111&", function(datajson){
			alert("dentro de restaurantes");

			/*alert(datajson[0].lat);*/
			var info;
			
			for(var i in datajson){		
				var dataJson = datajson[i];
				var latilongi = new google.maps.LatLng(dataJson.lat, dataJson.lon);
				var icono = "icons/comidarapida/kfc.png"
				marcador = new google.maps.Marker({
					position: latilongi,
					map: map,
					title:dataJson.restaurante
				});
			}			
		});
  }
  function mostrarUbicacion(){
		navigator.geolocation.getCurrentPosition( lecturaGPS , errorGPS , {enableHighAccuracy:true} )  
}
  function lecturaGPS(ubicacion){
	  
	  var miubicacion = new google.maps.LatLng(ubicacion.coords.latitude, ubicacion.coords.longitude);
	  map.setCenter(miubicacion)
	  marcador.setPosition(miubicacion)
	  
  }
  
  function errorGPS(){
	  alerta(" no puedo encontrarte :(")
  }
</script>
</head>
<body onload="initialize()">
  <div id="map_canvas" style="width:100%; height:90%"></div>
  <form>
   	<input type="button" value="¿Donde estoy?" id="ubicacion" onclick="mostrarUbicacion()">
   	<input type="button" value="Mostrar lugares" id="cajeros" onclick="buscarCrap()">
</form>
</body>
</html>